#include "testTreads.h"

void* thread_function(void* arg) {
    printf("这是子线程\n");
    int *a = malloc(sizeof(int));   
    *a=123;
    return (void*)a;
}

int main(){
    pthread_t my_thread;
    
    // 创建线程
    int result = pthread_create(&my_thread, NULL, thread_function, NULL);
    if (result != 0) {
        printf("线程创建失败\n");
        return 1;
    }
    
    printf("这是主线程\n");
    
    int* resultInt; 
    // 等待线程结束
    pthread_join(my_thread, (void **)&resultInt);
    printf("%d",*resultInt);
    return 0;
}